package com.tianshuo.mybatis.main;

import com.tianshuo.importtest.DefaultImport;
import com.tianshuo.mybatis.config.MyBatisSpringConfig;
import com.tianshuo.mybatis.model.UserDao;
import com.tianshuo.mybatis.model.UserServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @ClassName : AnnotationApplicationContextTest
 * @Description : 注解配置spring启动类
 * @Author : tianshuo
 * @Date: 2020-08-20 11:24
 */
public class MybatisApplicationContextTest {

	public static void main(String[] args) {

		AnnotationConfigApplicationContext applicationContext =
						new AnnotationConfigApplicationContext();
		applicationContext.register(MyBatisSpringConfig.class);
		applicationContext.refresh();


		DefaultImport defaultImport = applicationContext.getBean(DefaultImport.class);
		System.out.println(defaultImport);

		UserDao bean = applicationContext.getBean(UserDao.class);
//		UserServiceImpl bean = applicationContext.getBean(UserServiceImpl.class);
		System.out.println(bean);
		System.out.println(applicationContext.getBeanDefinition("userService").getClass());
		System.out.println(applicationContext.getBean(UserServiceImpl.class));

	}
}

